package com.igoal.entity;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class UserGoalPk implements Serializable{	
	private static final long serialVersionUID = 7758493783768839144L;
	
	private User user;
	private Goal goal;
	
	@ManyToOne
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@ManyToOne
	public Goal getGoal() {
		return goal;
	}
	public void setGoal(Goal goal) {
		this.goal = goal;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        UserGoalPk that = (UserGoalPk) o;
 
        if (user != null ? !user.equals(that.user) : that.user != null) return false;
        if (goal != null ? !goal.equals(that.goal) : that.goal != null) return false;
 
        return true;
	}
	
	@Override
	public int hashCode() {
		return this.user.hashCode()+this.goal.hashCode();
	}
}
